From 2a7e5226962c5c99f1a88055f58b40b515e0f90d Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Mon, 20 Dec 2021 01:56:48 +0100
Subject: [PATCH 09/11] use CBUILD_TARGET_SYSROOT to locate llvm when
 cross-compiling

---
 compiler/rustc_llvm/build.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
index 9fe59a1d8..230deaeaf 100644
--- a/compiler/rustc_llvm/build.rs
+++ b/compiler/rustc_llvm/build.rs
@@ -297,9 +297,11 @@ fn main() {
     for lib in output(&mut cmd).split_whitespace() {
         if is_crossed {
             if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
-                println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
+                println!("cargo:rustc-link-search=native={}{}",
+                         env::var("CBUILD_TARGET_SYSROOT").unwrap(), stripped);
             } else if let Some(stripped) = lib.strip_prefix("-L") {
-                println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
+                println!("cargo:rustc-link-search=native={}{}",
+                         env::var("CBUILD_TARGET_SYSROOT").unwrap(), stripped);
             }
         } else if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
             println!("cargo:rustc-link-search=native={stripped}");
-- 
2.39.0

